<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>FAF-商家中心</title>
<link rel="stylesheet" type="text/css" href="css/reset.css">
<link rel="stylesheet" type="text/css" href="css/main.css">
<link rel="stylesheet" type="text/css" href="css/mycss.css">
<link rel="stylesheet" type="text/css" href="css/file.css">
<link rel="stylesheet" type="text/css" href="css/button.css">
<script type="text/javascript" src="js/jquery-3.3.1.min.js"></script>
</head>
<body>
	<div class="header_con">
		<div class="header">
			<div class="welcome fl">欢迎来到好菜，好下饭!</div>
			<div class="fr">
				<div class="login_info fl">
					欢迎您：<em>张 山</em>
				</div>
				<div class="login_btn fl">
					<a href="/FAFCode/StoreLogout">注销</a>
				</div>
				<div class="user_link fl">
					<span>|</span> <a href="#">商家中心</a> <span>|</span> <a href="#">今日订单</a>
					<span>|</span> <a href="#">历史订单</a>
				</div>
			</div>
		</div>
	</div>

	<div class="search_bar clearfix">
		<a href="Index" class="logo fl"><img class="imgsize"
			src="/FAFCode/Image/logo/logo.jpg" width="80" height="80"></a>
		<div class="sub_page_name fl">|&nbsp;&nbsp;&nbsp;&nbsp;商家中心</div>
		<div class="search_con fr">
			<input type="text" class="input_text fl" name="" placeholder="搜索订单">
			<input type="button" class="input_btn fr" name="" value="搜索">
		</div>
	</div>

	<div class="main_con clearfix">
		<div class="left_menu_con clearfix">
			<h3>商家中心</h3>
			<ul>
				<li><a href="/FAFCode/PersonalInformation">· 个人信息</a></li>
				<li><a href="/FAFCode/OrderManagement/ViewOrders.jsp">·
						订单详情</a></li>
				<li><a href="/FAFCode/OrderManagement/Performance.html">·
						销售分析</a></li>
				<li><a href="#" class="active">· 新增菜品</a></li>
				<li><a href="/FAFCode/FoodManagement/manageFood.jsp">· 管理菜品</a></li>
				<li><a href="/FAFCode/FoodManagement/comment.jsp">· 查看评价</a></li>
			</ul>
		</div>

		<div class="right_content clearfix">
			<div class="info_con clearfix">
				<h3 class="common_title2">菜品信息</h3>
				<ul class="user_info_list">
					<li><span>菜名:</span><input type="text" id="foodName"
						name="foodName"></li>
					<li><span>价格:</span><input type="text" id="foodPrice"
						name="foodPrice"></li>
					<li><span>类型:</span><select id="foodType" name="foodType">
							<option value="炒菜">炒菜</option>
							<option value="凉菜">凉菜</option>
							<option value="速食">速食</option>
							<option value="主食">主食</option>
							<option value="饮品">饮品</option>
							<option value="水果">水果</option>
					</select></li>
					<li><span>详情描述:</span> <textarea rows="10" cols="20"
							id="foodDescribe" name="foodDescribe"></textarea></li>
					<li><input type="text" id="foodPhoto1" name="foodPhoto1"
						hidden="hidden" value="Image/goods/wenhao.jpg"></li>
				</ul>
			</div>

			<h3 class="common_title2">上传图片</h3>
			<div class="has_view_list">
				<ul class="goods_type_list clearfix">
					<li><a href="javascript:;" class="a-upload"><input
							type="file" id="foodPhoto" name="foodPhoto"
							onchange="loadImageFile(event)">点击这里上传图片</a><img id="image"
						name="image" src="../Image/goods/wenhao.jpg"> 
						<button id="save" name="save" class="button">保存</button></li>
				</ul>
			</div>

		</div>
	</div>
	<input type="text" id="storeId" name="storeId" hidden="hidden"
		value="${sessionScope.storeId}">
	<div class="footer">
		<div class="foot_link">
			<a href="#">关于我们</a> <span>|</span> <a href="#">联系我们</a> <span>|</span>
			<a href="#">招聘人才</a> <span>|</span> <a href="#">友情链接</a>
		</div>
		<p>CopyRight © 2016 北京天天生鲜信息技术有限公司 All Rights Reserved</p>
		<p>电话：010-****888 京ICP备*******8号</p>
	</div>
	<script>
		function loadImageFile(event) {
			var image = document.getElementById('image');
			image.src = URL.createObjectURL(event.target.files[0]);

		};
		$("#save")
				.click(
						function() {
							if (document.getElementById("foodName").value == "") {
								alert("请输入菜名!!!")
							} else if (document.getElementById("foodPrice").value == "") {
								alert("请输入价格!!!")
							} else if (!(document.getElementById("foodPrice").value
									.match(/^\+{0,1}\d+(\.\d{1,2})?$/) != null)) {
								alert("请输入正确的价格")
							} else if (document.getElementById("foodDescribe").value == "") {
								alert("请输入菜品描述!!!")
							} else {
								var foodPhoto = $("#foodPhoto")[0].files[0]
								var formdata = new FormData()
								formdata.append('storeId', $("#storeId").val())
								formdata.append('foodName', $("#foodName")
										.val())
								formdata.append('foodPrice', $("#foodPrice")
										.val())
								formdata.append('foodType', $("#foodType")
										.val())
								formdata.append('foodDescribe', $(
										"#foodDescribe").val())
								formdata.append('foodPhoto', foodPhoto)
								$
										.ajax({
											url : "../AddNewFoodManagement",
											type : 'post',
											processData : false,
											contentType : false,
											data : formdata,
											dataType : "json",
											success : function(data) {
												alert("新增菜品成功吖!")
												window.location.href = "addNewFood.jsp";
											}
										})
							}
						})
	</script>
</html>